﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _通用测试
{
    public static class ArrayUtil
    {
        /// <summary>
        /// 给数组添加一个元素
        /// </summary>
        /// <param name="nums"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public static int[] Add(this int[] nums, int num)
        {
            int[] res = new int[nums.Length + 1];
            for (int i = 0; i < nums.Length; i++)
            {
                res[i] = nums[i];
            }
            res[nums.Length] = num;
            return res;
        }

        /// <summary>
        /// 移除索引位置的数值
        /// </summary>
        /// <param name="nums">元数组</param>
        /// <param name="Index">索引</param>
        /// <returns></returns>
        public static int[] Remove(this int[] nums, int Index)
        {
            int[] res = new int[nums.Length - 1];
            int n = 0;
            for (int i = 0; i < nums.Length; i++)
            {
                if (i != Index)
                {
                    res[n] = nums[i];
                    n++;
                }
            }
            return res;
        }
    }
}
